﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;

namespace WebSys.UI.Control.ZhengShou
{
    public class ZS_ProjectBZXXGSControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        CustomGridView GridList;
        Button btnsearch;
        TextBox xmmc, lxh;
        //public static string userid = HttpContext.Current.Session["UserID"].ToString();
        public string userid = string.Empty;

        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            base.OnLoad(e);
            InitControl();
            if (!base.Page.IsPostBack)
            {
                Bind();
            }

        }

        protected void Bind()
        {
            string sql = "Select * from zs_project where 1=1 ";
            string xm = xmmc.Text;
            if (!string.IsNullOrEmpty(xm))
            {
                sql += " and 项目名称 like '%" + xm + "%'";
            }
            string lx = lxh.Text;
            if (!string.IsNullOrEmpty(lx))
            {
                sql += " and 立项号 like '%" + lx + "%'";
            }
            DataTable dt = _EluZSDataProvider.GetTable(sql);
            if (dt.Rows.Count > 0)
            {
                GridList.DataSource = dt;
                GridList.RecordCount = dt.Rows.Count;
                GridList.DataBind();
            }
        }

        
        protected void InitControl()
        {
            btnsearch = (Button)FindControl("btnsearch");
            btnsearch.Click += new EventHandler(btnsearch_Click);
            GridList = (CustomGridView)FindControl("GridList");
            GridList.OnLoadData += new EventHandler(GridList_OnLoadData);
            xmmc = (TextBox)FindControl("xmmc");
            lxh = (TextBox)FindControl("lxh");
        }

        protected void btnsearch_Click(object sender, EventArgs e)
        {
            Bind();
        }

        protected void GridList_OnLoadData(object sender, EventArgs e)
        {
            Bind();
        }

    }
}


